import {reactive, ref} from 'vue'
export function UserPagination(loadData:()=>Promise<any>,initalPageSize=10){
    const total = ref(0)
    const pageInfo = reactive({
        page:1,
        pageSize:initalPageSize
    })
    const handleCurrentChange = (page:number)=>{
        pageInfo.page = page
        loadData()
    }
    const handleSizeChange = (size:number)=>{
        pageInfo.pageSize = size
        loadData()
    }
    const setTotal = (all:number)=>{
        total.value = all
    }
    return {total,pageInfo,handleCurrentChange,handleSizeChange,setTotal}
}